#ifndef __LINKTREE_H_
#define __LINKTREE_H_
#define TreeElementType char*
#include "DoubleLinkList.h"
#include <stdbool.h>

struct TreeNode;
typedef struct TreeNode TNode;

//创建树节点
TNode *CreateTreeNode(TreeElementType element);
//获取节点数据
void *GetTreeNodeData(TNode *node);

//连接
void ConnectBranch(TNode *parent,TNode *child);
//断开
void DisconnectBranch(TNode *parent,TNode *child);
//查找
TNode *FindChildNode(TNode *parent,void *value,bool(*funcPtr)(void *,void *));

//释放树
void FreeTreeNode(void *node);


struct LinkTree;
typedef struct LinkTree LTree;

//初始化
LTree *InitLinkTree();
//获取树的根节点
TNode *GetTreeRoot(LTree *tree);
//获取树高
int GetTreeHeight(LTree *tree);
//打印树
void TravelTree(LTree *tree,void(*funcPtr)(void *));
//查找节点
TNode *FindLinkTreeNode(LTree *tree,void* value,bool(*funcPtr)(void *,void *));
//找到所有的叶子节点
DLlist FindAllLeafBranch(LTree *tree);
//释放整个树
void ClearLinkTree(void *tree);

#endif